<section class="content-header">
  <h1>
    Contests
    <small>{{ ctrl.contests.length }} contests</small>
  </h1>
  <ol class="breadcrumb">
    <li><a ui-sref="manage"><i class="fa fa-wrench"></i> Manage</a></li>
    <li class="active">Contests</li>
  </ol>
</section>

<section class="content">
  <div class="box box-primary">
    <div class="box-header with-border">
      <h3 class="box-title">All Contests</h3>
      <span style="margin-left: 20px">
        Current contest:
        <select ng-model="ctrl.currentContestId">
          <option value="">None</option>
          <option ng-repeat="contest in ctrl.contests" value="{{ contest._id }}">{{ contest.name }}</option>
        </select>
        <button class="btn btn-box-tool" ng-click="ctrl.doSetCurrentContest()">
          Update
        </button>
      </span>
      <div class="box-tools pull-right">
        <a class="btn btn-box-tool" ui-sref="manage_contest_create">
          <i class="fa fa-plus"></i> Create
        </a>
      </div>
    </div>
    <div class="box-footer" ng-show="ctrl.contests.length == 0">
      No contests
    </div>
    <div class="box-body no-padding" ng-show="ctrl.contests.length > 0">
      <div class="table-responsive">
        <table class="table table-hover table-striped">
          <tbody>
          <tr>
            <th>{{ 'ui.page.contest.list.col.name' | translate }}</th>
            <th style="width:100px">{{ 'ui.page.contest.list.col.challenges' | translate }}</th>
            <th style="width:100px">{{ 'ui.page.contest.list.col.registrants' | translate }}</th>
            <th style="width:120px">{{ 'ui.page.contest.list.col.state' | translate }}</th>
            <th style="width:120px">{{ 'ui.page.contest.list.col.regState' | translate }}</th>
            <th style="width:150px">{{ 'ui.page.contest.list.col.begin' | translate }}</th>
            <th style="width:150px">{{ 'ui.page.contest.list.col.end' | translate }}</th>
          </tr>
          <tr ng-repeat="contest in ctrl.contests">
            <td><a ui-sref="manage_contest_info({id: contest._id})">{{ contest.name }}</a></td>
            <td>{{ contest.challengeCount||0 }}</td>
            <td>{{ contest.registrantCount||0 }}</td>
            <td>{{ ('contest.state.' + contest.state) | translate }}</td>
            <td>{{ ('contest.regState.' + contest.regState) | translate }}</td>
            <td><span data-balloon="{{ contest.begin | date: 'yyyy-MM-dd (EEE) HH:mm:ss Z' }}">{{ contest.begin | amCalendar }}</span></td>
            <td><span data-balloon="{{ contest.end | date: 'yyyy-MM-dd (EEE) HH:mm:ss Z' }}">{{ contest.end | amCalendar }}</span></td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</section>
